/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cip.esymons.tesoreria.bc;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
import org.cip.esymons.general.be.PersonaJuridica;
import org.cip.esymons.tesoreria.be.CobroPlanilla;
import org.cip.esymons.tesoreria.be.DetCobroPlanilla;
import org.cip.esymons.tesoreria.be.EnumEstadoCobroPlanilla;
import org.cip.esymons.tesoreria.be.EnumMeses;

/**
 *
 * @author Ingrid
 */
public class CobroPlanillaDelegate {
    private CobroPlanillaFacadeLocal local;

    public CobroPlanillaDelegate() {
        local = lookupCobroPlanillaFacade();
    }

    public void remove(CobroPlanilla cobroPlanilla) {
        local.remove(cobroPlanilla);
    }

    public List<CobroPlanilla> findAll() {
        return local.findAll();
    }

    public CobroPlanilla find(Object id) {
        return local.find(id);
    }

    public void edit(CobroPlanilla cobroPlanilla) {
        local.edit(cobroPlanilla);
    }

    public void create(CobroPlanilla cobroPlanilla) {
        local.create(cobroPlanilla);
    }

    public List<PersonaJuridica> listaTodasEmpresasConPlanillaColegiados(){
        return local.listaTodasEmpresasConPlanillaColegiados();
    }

    public  List<CobroPlanilla> colegiadosActivosYCesantes(PersonaJuridica empresa){
        return local.colegiadosActivosYCesantes(empresa);
    }


    public List<DetCobroPlanilla> listaDetalleCobroPlanilla(CobroPlanilla cobroPlanilla){
        return local.listaDetalleCobroPlanilla(cobroPlanilla);
    }

    public List<DetCobroPlanilla> listaPagosXCobroPlanilla(EnumMeses mes, int anio) {
        return local.listaPagosXCobroPlanilla(mes, anio);
    }

    public List<DetCobroPlanilla> listaCobroPlanillaXColegiado(Long colegiado, EnumMeses mes, int anio,EnumEstadoCobroPlanilla enumEstadoCobroPlanilla) {
        return local.listaCobroPlanillaXColegiado(colegiado, mes, anio, enumEstadoCobroPlanilla);
    }

    public EntityManager getEm() {
        return local.getEm();
    }

    private CobroPlanillaFacadeLocal lookupCobroPlanillaFacade() {
        try {
            Context c = new InitialContext();
            return (CobroPlanillaFacadeLocal) c.lookup("java:comp/env/CobroPlanillaFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }
}
